package org.example.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.domain.Role;
import org.example.mapper.RoleMapper;
import org.example.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    RoleMapper roleMapper;

    @Override
    public PageInfo<Role> list(Role role, Page page) {

        PageHelper.startPage((int) page.getCurrent(), (int) page.getSize());
        List<Role> list=roleMapper.list(role);
        PageInfo<Role> info = new PageInfo<>(list);
        return info;
    }

    @Override
    public void del(Integer id) {
        roleMapper.del(id);
    }

    @Override
    public void update(Role role) {
        roleMapper.update(role);
    }

    @Override
    public void add(Role role) {
        roleMapper.add(role);
    }

    @Override
    public List<Role> lists() {
        return roleMapper.lists();
    }

    @Override
    public Role getById(Integer id) {
      Role role=  roleMapper.getById(id);
        return role;
    }
}
